// page/component/category/category.js
Page({
  data: {
    category: [
      { name: '粥类', id: 'guowei' },
      { name: '烙饼', id: 'shucai' },
      { name: '面点', id: 'dianxin' }
    ],
    detail: [
      {
        "id": "guowei",
        "banner": "/images/c1.png",
        "cate": "粥类",
        "detail": [
          {
            "thumb": "/images/z1.png",
            "name": "皮蛋瘦肉粥"
          },
          {
            "thumb": "/images/z2.png",
            "name": "八宝粥"
          },
          {
            "thumb": "/images/z3.png",
            "name": "胡辣汤"
          }
        ]
      },
      {
        "id": "shucai",
        "banner": "/images/c1.png",
        "cate": "烙饼",
        "detail": [
          {
            "thumb": "/images/b4.png",
            "name": "酱香饼"
          },
          {
            "thumb": "/images/b5.png",
            "name": "蛋饼"
          },
          {
            "thumb": "/images/b6.png",
            "name": "手抓饼"
          }
        ]
      },
      {
        "id": "dianxin",
        "banner": "/images/c1.png",
        "cate": "面点",
        "detail": [
          {
            "thumb": "/images/b7.png",
            "name": "油条"
          },
          {
            "thumb": "/images/b8.png",
            "name": "蒸饺"
          },
          {
            "thumb": "/images/b9.png",
            "name": "包子"
          }
        ]
      }
    ],
    curIndex: 0,
    isScroll: false,
    toView: 'guowei'
  },
  // onReady() {
  //   var self = this;
  //   wx.request({
  //     url: 'http://localhost:3000/miniData',
  //     success(res) {
  //       console.log(res.data);
  //       self.setData({
  //         detail: res.data
  //       })
  //     }
  //   });

  // },
  switchTab(e) {
    const self = this;
    this.setData({
      isScroll: true
    })
    setTimeout(function () {
      self.setData({
        toView: e.target.dataset.id,
        curIndex: e.target.dataset.index
      })
    }, 0)
    setTimeout(function () {
      self.setData({
        isScroll: false
      })
    }, 1)

  }

})